package com.ccsc.auth.cas.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.ccsc.auth.cas.entity.*;
import com.ccsc.auth.cas.entity.vo.User;
import com.ccsc.auth.cas.utils.EntityUtil;
import org.jasig.services.persondir.IPersonAttributes;
import org.jasig.services.persondir.support.AttributeNamedPersonImpl;
import org.jasig.services.persondir.support.StubPersonAttributeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;

/**
 * Created by XingWen on 2015/11/17.
 */

@Service
public class SdpStubPersonAttributeService extends StubPersonAttributeDao {
    @Autowired
    private UserService userService;

    @Override
    public IPersonAttributes getPerson(String uid) {
        Map<String, List<Object>> attributes = new HashMap<String, List<Object>>();
        //KMGA修改为username
        SysUserEntity sysUserEntity = userService.getSysUserInfo(uid);
        //User user = EntityUtil.convEntity2User(userEntity);
        attributes.put("casUserInfo", Collections.singletonList((Object) JSON.toJSONString(sysUserEntity, SerializerFeature.BrowserCompatible)));
        return new AttributeNamedPersonImpl(attributes);
    }
}
